<?php

require_once('class/restrictpage.php');
canConnectFor("ALL");
require_once('AjaxCall_Action_Utility/convertMSG.php');
require_once './Connections/connect.php';
//require_once('../Connections/conn.php');

require_once('class/Product_display.function.php');
if(!empty($_GET['proChange'])){changeshow($_GET['proChange']);}
//else if(!empty($_GET['del'])){del($_GET['del']);}
else if(!empty($_GET['proRedirect'])){$ids=proDC("show",$id);}

$queryExecutor = new QueryExecutor();

$categoryList_sql = "SELECT categoryId,category,parent_cate,offset FROM sme_category ORDER BY offset ASC ,categoryId ASC ";
$categoryList = $queryExecutor->execute($categoryList_sql);

$brandList_sql = "SELECT brandId,brandName FROM sme_brand  ORDER BY brandId ASC";
$brandList = $queryExecutor->execute($brandList_sql);

$queryExecutor->close();
?>
<!doctype html>
<html lang="th"><!-- InstanceBegin template="/Templates/temp.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<?php 
$setac= array();
for($i=0;$i<9;$i++)
$setac[$i]="";
?>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet"  href="backstore_css.css" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>หลังร้าน &gt;&gt; จัดการสินค้า</title>
<script type="text/javascript" src="inc/jquery-1.11.0.min.js"  charset="UTF-8"></script>
<style type="text/css">
body,td,th {
	font-family: Tahoma, Geneva, sans-serif;
}
table tr.even:hover th, table tr.even:hover td, table tr.hover th {
    background: none repeat scroll 0 0  #F2F2F2;
}
.require {font-size: 16px;
	color: #F00;
}
</style>
<?php $setac[2-1]="class=\"active\""; ?>
<!-- InstanceEndEditable -->
<link rel="icon" type="image/x-icon" id="favicon" href="img/faviconc.ico"/>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body>
<div id="contain">
<?php require("inc/menu_admin.php") ?>
<div id="main">
<ul id="submenu">
<!-- InstanceBeginEditable name="EditRegion2" -->
<?php require("inc/menu_product.php") ?>
<!-- InstanceEndEditable -->			
</ul>
<div id="content">
<div class="path_bar">
<!-- InstanceBeginEditable name="EditRegion6" -->
<img src="img/prefs.gif" alt="" style="margin-right: 10px;"/><a href="#">หลังร้าน</a> &gt;&gt;
<img src="img/admin/tab-products.gif" alt="" style="margin-right: 5px;"/>
สินค้า<!-- InstanceEndEditable -->
</div>
<!-- InstanceBeginEditable name="EditRegion1" -->
<div class="align-center">
    <form id="form1" name="form1" method="post" action="javascript:void(0);">
        <table  align="center">
            <tr>
                <th class="align-left">คำค้นหา</th>
                <td class="align-left">
                    <input name="keywordSearch" type="text" id="keywordSearch"  size="70" />
                    <br />
                    ใส่รหัสสินค้า หรือชื่อสินค้า หากว่างไว้จะแสดงรายการสินค้าทั้งหมดตามตัวเลือกด้านล่าง
                </td>
            </tr>
            <tr>
                <th class="align-left">จากหมวดหมู่</th>
                <td class="align-left">
                    <select name="categorySearch" id="categorySearch">
                        <option value="">ทุกหมวดหมู่</option>
                        <?php
                        $off = 0;
                        foreach ($categoryList as $ct){
                        ?>
                        <option value="<?= $ct[0]; ?>"  >
                         <?php
                                if (!$ct["parent_cate"]) {
                                    $off++;
                                    echo "[$off]" . $ct[1];
                                }
                                else
                                    echo "---[$off]" . $ct[1];
                                ?>
                            </option>
                        <?php } ?>
                    </select>
                </td>
            </tr>
            <tr>
                <th >จากตราสินค้า </th>
                <td class="align-left">
                    <select name="brandSearch" id="brandSearch">
                        <option value="">ทุกตราสินค้า</option>
                        <option value="0">ที่ไม่มีตราสินค้า</option>
                            <?php
                                foreach ($brandList as $bd){
                                echo "<option value=\"" . $bd[0] . "\" >" . $bd[1] . "</option>";
                            }
                            ?>
                    </select>
                </td>
            </tr>
            <tr >
                <td colspan="2" style="text-align: center">
                    <input id="submit"  type="button" value="ค้นหาสินค้า" />
                </td>
            </tr>
        </table>
    </form>
</div>
<div id="productList">
</div>

<!-- InstanceEndEditable -->
</div>
</div>
</div>
<?php require("inc/footer_admin.php") ?>
</body>
<!-- InstanceEnd -->
<script  type="text/javascript">
$( "#productList" ).load( "./AjaxCall/product/productList.php" );
    
$("#submit").click(function() {	
   var keyword = $( "#keywordSearch" ).val();
   var category = $( "#categorySearch" ).val();
   var brand = $( "#brandSearch" ).val();
   var href = "?keywordSearch="+keyword+"&categorySearch="+category+"&brandSearch="+brand;
   $( "#productList" ).load( "./AjaxCall/product/productList.php"+href );
});

</script>
</html>
